package de.artmann.powerfit;

import android.app.Activity;
import android.app.AlertDialog;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;


public class Activity1 extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_activity1);
        final ListView listView = (ListView)findViewById(R.id.listView);
        final TextView textView = (TextView) findViewById(R.id.textView);
        final LinearLayout linearLayout = (LinearLayout) findViewById(R.id.innerLinearLayout);
        final Button textViewButton = (Button) findViewById(R.id.textViewButton);
        final String[] stringValues = new String[]
                {"Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag", "Sonnntag"};

        List<String> valueList = new ArrayList<String>();
        for(int i = 0; i < stringValues.length; i++) {
            valueList.add(stringValues[i]);
        }
        ListAdapter listAdapter =
                new ArrayAdapter<String>(getApplicationContext(), R.layout.list_item, valueList);
        listView.setAdapter(listAdapter);
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                Object o = listView.getItemIdAtPosition(i);
                AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(Activity1.this);
                if (o.toString().equals("0")) {
                    //textView.setText("08:00 - 10:00 Uhr\n16:00 - 21:00 Uhr");
                    alertDialogBuilder.setMessage(R.string.oeffnung_montag)
                            .setNeutralButton(R.string.ok, null)
                            .show();
                } else if (o.toString().equals("1")) {
                    //textView.setText("16:00 - 21:00 Uhr");
                    alertDialogBuilder.setMessage(R.string.oeffnung_dienstag)
                            .setNeutralButton(R.string.ok, null)
                            .show();
                } else if (o.toString().equals("2")) {
                    //textView.setText("08:00 - 10:00 Uhr\n16:00 - 21:00 Uhr");
                    alertDialogBuilder.setMessage(R.string.oeffnung_mittwoch)
                            .setNeutralButton(R.string.ok, null)
                            .show();
                } else if (o.toString().equals("3")) {
                    //textView.setText("08:30 - 10:30 Uhr\n16:00 - 21:00 Uhr");
                    alertDialogBuilder.setMessage(R.string.oeffnung_donnerstag)
                            .setNeutralButton(R.string.ok, null)
                            .show();
                } else if (o.toString().equals("4")) {
                    //textView.setText("16:00 - 21:00 Uhr");
                    alertDialogBuilder.setMessage(R.string.oeffnung_freitag)
                            .setNeutralButton(R.string.ok, null)
                            .show();
                } else if (o.toString().equals("5")) {
                    //textView.setText("15:00 - 17:30 Uhr");
                    alertDialogBuilder.setMessage(R.string.oeffnung_samstag)
                            .setNeutralButton(R.string.ok, null)
                            .show();
                } else if (o.toString().equals("6")) {
                    //textView.setText("09:00 - 11:30 Uhr\n16:00 - 18:30 Uhr");
                    alertDialogBuilder.setMessage(R.string.oeffnung_sonntag)
                            .setNeutralButton(R.string.ok, null)
                            .show();
                }
                //linearLayout.setVisibility(View.VISIBLE);
            }

        });//endOnItemClickListener
        /*
        textViewButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                linearLayout.setVisibility(View.GONE);
            }
        });
        */
    }//endOnCreate


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity1, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}
